package com.firewolf.springcloud.controller;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.firewolf.springcloud.entities.Dept;
import com.firewolf.springcloud.service.DeptService;

@RestController
public class DeptController {
	
	
	Logger logger = LoggerFactory.getLogger(DeptController.class);

	@Autowired
	private DeptService deptService;
	
	@PostMapping("add")
	public int addDept(@RequestBody Dept d){
		return deptService.addDept(d);
	}
	
	@GetMapping("list")
	public List<Dept> list(){
		return deptService.list();
	}
	
	@GetMapping("find/{id}")
	public Dept findByID(@PathVariable("id") Integer id){
		return deptService.findByID(id);
	}
	
	@DeleteMapping("del/{id}")
	public int deleteDept(@PathVariable("id") Integer id){
		return deptService.deleteDepte(id);
	}
}
